package com.itheima.list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Demo1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();

        list.add("liuqi");
        list.add("qiqi");

        ListIterator<String> it = list.listIterator();
        while (it.hasNext()){
            if("liuqi".equals(it.next())){
                it.add("昊志");//必须要用迭代器添加才不会并发修改异常
                list.add("超原");//ConcurrentModificationException
            }
        }
    }
}
